package com.qing.deep_in.springboot.chapter4.aspect;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author guoqf
 * @date 2021/9/11 21:46
 */
@Component
@Aspect
public class MyAspect {


    @Pointcut("execution(* com.qing.deep_in.springboot.chapter4.aspect.service.impl.UserServiceImpl.addUser(..))")
    public void pointCut(){

    }

    @Before("pointCut()")
    public void before() {
        System.out.println("=======before in MyAspect");
    }

    @After("pointCut()")
    public void after() {
        System.out.println("=======after in MyAspect");
    }


    @AfterReturning("pointCut()")
    public void afterReturning() {
        System.out.println("=======afterReturning in MyAspect");
    }


    @AfterThrowing("pointCut()")
    public void afterThrowing() {
        System.out.println("=======AfterThrowing in MyAspect");
    }

}
